package com.example.yiwei.crm.view.Class.listviewClass;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.yiwei.crm.R;
import com.example.yiwei.crm.entity.CustomerMessageEntity;

import java.util.List;

/**
 * Created by DHN on 2017/6/27.
 */

public class SimpleCoorCustomerAdapter extends BaseAdapter{
    public static List<CustomerMessageEntity> list;
    CustomerMessageEntity customer;
    private LayoutInflater inflater ;
    private Context context;
    public SimpleCoorCustomerAdapter(Context context, List<CustomerMessageEntity> list){
        this.context = context;
        this.list = list;
        inflater =LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
       ViewHolder holder;
        customer = list.get(position);
        if (convertView==null){
            convertView = inflater.inflate(R.layout.layout_item_simpl_customer,null);
            holder = new ViewHolder();
            holder.name = (TextView) convertView.findViewById(R.id.tv_device_name);
            holder.phone = (TextView) convertView.findViewById(R.id.tv_device_phone);
//            holder.cname = (TextView) convertView.findViewById(R.id.item_gift_cname);
//            holder.cdata = (TextView) convertView.findViewById(R.id.item_gift_cdata);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.name.setText(customer.getClient_name());
        holder.phone.setText(customer.getContact_phone_number());
//        holder.cname.setText(giftEntity.getCname());
//        holder.cdata.setText(giftEntity.getCdata());
        return convertView;
    }

    class ViewHolder{
        TextView name;
        TextView phone;
    }
}
